package com.example.controller;

import com.example.utils.HTTPUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {
    @Resource
    private HTTPUtils httpUtils;

    @GetMapping("test/{n}")
    public String test(@PathVariable Integer n){

        long start = System.currentTimeMillis();

        for (int i = 0; i < n; i++) {
            httpUtils.request();
        }

        long end = System.currentTimeMillis();
        return "一共耗时: " + (end-start) + " 毫秒,约为 " + (end-start)/1000 + "秒";
    }
}
